package com.iqik.sc.ns.service;

import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
//import org.springframework.mail.MailSender;
//import org.springframework.mail.SimpleMailMessage;

@Service
public class EmailServiceImpl implements EmailService {

//    @Autowired
//    private MailSender mailSender;

    @Value("${spring.mail.username}")
    private String fromEmail;

    @Override
    public boolean sendCode(String toEmail, String code) {
        try {
//            SimpleMailMessage message = new SimpleMailMessage();
//            message.setFrom(fromEmail);
//            message.setTo(toEmail);
//            message.setSubject("验证码");
//            message.setText(code);
//            mailSender.send(message);
            System.out.println("from email [" + fromEmail + "]send code: " + code + " to email: " + toEmail);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}
